<?php

namespace App\Kuafu\Order\Model;

use App\Kuafu\Base\Model\BaseModel;
use App\Kuafu\Order\Enum\CodeEnum;

class OrderInvoiceModel extends BaseModel
{
    protected $table      = 'order_invoice';
    protected $primaryKey = 'id';

    protected $fillable = [
        'brandId',
        'shopId',
        'orderId',
        'orderType',
        'jshj',
        'hjje',
        'hjse',
        'fpdm',
        'fphm',
        'fplxdm',
        'status',
        'invoiceUrl',
        'supplier',
        'createdAt',
        'updatedAt',
        'createdByUid',
        'updatedByUid'
    ];

    // 订单来源
    public const ORDER_INVOICE_DB_ORDER_TYPE_POS    = CodeEnum::SOURCE_TYPE_SHOP;   // 堂食
    public const ORDER_INVOICE_DB_ORDER_TYPE_WAIMAI = CodeEnum::SOURCE_TYPE_WAIMAI;  // 外卖

    // 开票服务商
    public const ORDER_INVOICE_DB_SUPPLIER_MERODO = 1; // 盟度开票服务商

    // 发票状态
    public const ORDER_INVOICE_STATUS_VALID        = 1; // 有效
    public const ORDER_INVOICE_STATUS_RED_CANCELED = 2; // 红冲
    public const ORDER_INVOICE_STATUS_CANCEL       = 3; // 取消
    public const ORDER_INVOICE_STATUS_APPLY        = 4; /// 默认状态 - 提交开票状态

    public const ORDER_TYPE_TAKE_OUT = 'W'; //外卖
    public const ORDER_TYPE_HALL     = 'T'; //堂食
    public const ORDER_CALLBACK_RED  = 'hc-'; //红冲

    public static function addData($data)
    {
        $model = self::query()
                     ->create($data);
        return $model->id;
    }


}